﻿<phone:PhoneApplicationPage
    x:Class="SmarterCharger.App.Views.FirstTimeUserPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:converters="clr-namespace:SmarterCharger.App.Converters"
    mc:Ignorable="d"
    d:DesignHeight="3001"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,12">
            <Image Source="../Assets/Logo.png" Height="159" Margin="12, 0, 0, 24" HorizontalAlignment="Left" />
            <TextBlock Text="{Binding Path=LocalizedResources.PageTitle_FirstTimeUser, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextTitle2Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            
            <ProgressBar IsIndeterminate="True" Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>

            <ScrollViewer x:Name="scroller" Grid.Row="1" Template="{StaticResource ScrollViewerWithIndication}">
                <StackPanel>
                    <!--PurposePanel explains the reason to use this app-->
                    <StackPanel x:Name="PurposePanel">
                        <TextBlock Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Height="Auto">
                        Smarter charger <Bold>spares</Bold> your phone <Bold>battery</Bold>
                        by putting your <Bold>Smart Energy Toolkit</Bold> to use
                        </TextBlock>
                    </StackPanel>

                    <!--StartPanel explains how to grant access-->
                    <StackPanel x:Name="StartPanel">
                        <Grid Margin="12, 36, 12, 0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <Image Source="../Assets/GrantAccess.png" Height="159" />

                            <StackPanel Grid.Column="1">
                                <TextBlock Text="{Binding Path=LocalizedResources.Title_StepStart, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextTitle2Style}" Margin="18,0,0,12"/>
                                <TextBlock Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Margin="18,0,0,0">
                                <Bold>Allow access</Bold> to your Smart Energy Toolkit 
                                by <Bold>entering</Bold> your <Bold>credentials</Bold> below
                                </TextBlock>
                            </StackPanel>
                        </Grid>
                    </StackPanel>

                    <!--CredentialsPanel accepts the login-->
                    <StackPanel x:Name="CredentialsPanel" Margin="0, 36, 0, 0">
                    <StackPanel>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text="{Binding Path=LocalizedResources.Label_Username, Source={StaticResource LocalizedStrings}}"/>
                            <toolkit:PhoneTextBox Text="{Binding Username, Mode=TwoWay}"
                                              InputScope="EmailUserName"
                                              Hint="user@fifthplay.com"
                                              IsEnabled="{Binding IsLoading, Converter={StaticResource BooleanNegationConverter}}" 
                                              KeyUp="UsernameKeyUp" />
                    </StackPanel>
                    <StackPanel>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text="{Binding Path=LocalizedResources.Label_Password, Source={StaticResource LocalizedStrings}}" />
                        <PasswordBox Password="{Binding Password, Mode=TwoWay}" 
                                    x:Name="Password" 
                                    IsEnabled="{Binding IsLoading, Converter={StaticResource BooleanNegationConverter}}"
                                    KeyUp="PasswordKeyUp" />
                        </StackPanel>
                </StackPanel>

                    <!--ChoosePanel explains why to choose a smart plug-->
                    <Grid x:Name="ChoosePanel" Margin="12, 12, 12, 0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <StackPanel>
                            <TextBlock Text="{Binding Path=LocalizedResources.Title_StepChoose, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextTitle2Style}" Margin="0,0,0,12"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Margin="0,0,0,0">
                            Choose which <Bold>smart plug</Bold> your phone <Bold>charger</Bold> will be plugged into
                            </TextBlock>
                        </StackPanel>

                        <Image VerticalAlignment="Bottom" Grid.Column="1" Source="../Assets/ChoosePlug.png" Height="100" />
                    </Grid>

                    <!--SmartPlugPanel lists the found smart plugs-->
                    <StackPanel x:Name="SmartPlugPanel" Margin="0, 18, 0, 0">
                        <toolkit:ListPicker x:Name="Plugs" 
                                            ItemsSource="{Binding SmartPlugs}"
                                            IsEnabled="{Binding IsCredentialsValid}" 
                                            SelectedItem="{Binding SelectedSmartPlug, Mode=TwoWay}"
                                            Header="{Binding Path=LocalizedResources.Label_ChoosePlug, Source={StaticResource LocalizedStrings}}" 
                                            DisplayMemberPath="Name"
                                            SelectionMode="Single" ExpansionMode="FullScreenOnly" 
                                            FullModeHeader="{Binding Path=LocalizedResources.Label_ChoosePlug, Source={StaticResource LocalizedStrings}}">
                            <toolkit:ListPicker.FullModeItemTemplate>
                                <DataTemplate>
                                    <StackPanel Margin="0, 12">
                                        <TextBlock Text="{Binding Name}"
                                                   Style="{StaticResource PhoneTextLargeStyle}"></TextBlock>
                                        <TextBlock Text="{Binding SerialNumber}" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>
                                    </StackPanel>
                                </DataTemplate>
                            </toolkit:ListPicker.FullModeItemTemplate>
                        </toolkit:ListPicker>
                    </StackPanel>

                    <!--ConclusionPanel completes setup and explains how to continue-->
                    <Grid x:Name="ConclusionPanel" Margin="12, 12, 12, 0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <Image x:Name="Hypnosis" VerticalAlignment="Center" Source="../Assets/Hypnosis.png" Height="150" />

                        <StackPanel Grid.Column="1">
                            <TextBlock Grid.ColumnSpan="2" Text="{Binding Path=LocalizedResources.Title_StepComplete, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextTitle2Style}" Margin="12,0,0,12"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap">
                                From now on, each time you plug in your phone charger, start up this app and things will be great.
                            </TextBlock>

                            <Button x:Name="Charge" 
                                Command="{Binding ChargeCommand}"
                                Margin="0,30,0,0"
                                Content="{Binding Path=LocalizedResources.Button_Start, Source={StaticResource LocalizedStrings}}" />
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </ScrollViewer>
        </Grid>

        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="../Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
    </Grid>
</phone:PhoneApplicationPage>